<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 编写函数 获取四位随机验证码 "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
        var str = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'; // 62个
        // 索引 0----61  整数
        function Seccode(n) {
            var code = '';
            for (var i = 0; i < n; i++) {
                random = Math.floor(Math.random()*62);
                code += str.charAt(random);
            }
            return code;
        }
        console.log(Seccode(6));
    </script>
</body>
</html>